/**
 * Created by isoft-work 5 on 11/16/14.
 */

$(document).ready(function(){
//   render
   renderUserAccount();
//   event
});

function renderUserAccount() {
   var useName = ISS.SESSION.getSession('userName') ? ISS.SESSION.getSession('userName') : ISS.COOKIE.getCookie('userName');
   if(!useName) {
      ISS.WINDOW.location('/jsp/user/user-login.jsp');
   }
   else {
      getInfoUser(useName);
   }
}

function getInfoUser(useName) {
   var user = {};
   user.maTV = useName;
   ISS.BACKEND.request({
      url: ISS.SESSION.getSession('contextPath') + '/service/EditAccount/getInfoUser/',
      headers: {
         'Accept': 'application/json',
         'Content-Type': 'application/json'
      },
      type: 'POST',
      dataType: 'json',
      data: JSON.stringify(user),
      success: function (data) {
         var responseInfo = data.responseObject;
         getInfoUserComplete(responseInfo);
      }
   });
}

function getInfoUserComplete(userInfo){
   var _ngaySinh = new Date(userInfo.ngaySinh);
   ISS.DOM.text('#account_email', userInfo.maTV);
   ISS.DOM.text('#account_full_name',userInfo.ho + ' ' + userInfo.ten);
   ISS.DOM.text('#account_date', ISS.DATE.getFullDate(_ngaySinh));
}